package cn.zwx.member.svc.service.impl;

import cn.zwx.member.svc.domain.entity.MemberEntity;
import cn.zwx.member.svc.mapper.MemberMapper;
import cn.zwx.member.svc.service.MemberService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author zhangwenxue
 */
@Service
public class MemberServiceImpl implements MemberService {

    @Resource
    private MemberMapper memberMapper;


    @Override
    public MemberEntity selectMemberById(String userId) {
        return memberMapper.selectById(userId);
    }

    @Override
    public MemberEntity selectMemberByMobile(String mobile) {
        LambdaQueryWrapper<MemberEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MemberEntity::getMobile,mobile);
        return memberMapper.selectOne(queryWrapper);
    }

    @Override
    public void insert(MemberEntity entity) {
        memberMapper.insertSelective(entity);
    }

    @Override
    public void update(MemberEntity memberEntity) {
        memberMapper.updateByPrimaryKeySelective(memberEntity);
    }
}
